package oj;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

public class LC78 {
    public List<List<Integer>> subsets(int[] nums) {
        if(nums.length==0){
            return new ArrayList<>();
        }
        List<List<Integer>> list=new ArrayList<>();
        List<Integer> path=new LinkedList<>();
        dfs(nums,0,list,path);
        return list;

    }
    private void dfs(int[] nums,int i,List<List<Integer>> list,List<Integer> path){
        if(i==nums.length){
            list.add(new ArrayList<>(path));
            return;
        }
        path.add(nums[i]);
        dfs(nums,i+1,list,path);
        path.remove(path.size()-1);
        dfs(nums,i+1,list,path);

    }
}
